return `\n\nStack trace:\n${indentedStack}`;
}
-function formatExceptionWithCause(error, seenCauses) {
- let fmt = formatExceptionStack(error);
+function formatExceptionWithCause(error, seenCauses, showStack) {
+ let fmt = showStack ? formatExceptionStack(error) : '';
const {cause} = error;
if (!cause)
* location where a SyntaxError was thrown into account.
*
* @param {Error} error The error to format
+ * @param {object} options Formatting options
+ * @param {boolean} options.showStack Whether to show the stack trace (default
+ * true)
* @returns {string} The formatted string
*/
-export function formatError(error) {
+export function formatError(error, {showStack = true} = {}) {
try {
let fmt = `${error}`;
if (error === null || typeof error !== 'object')
if (error instanceof SyntaxError) {
fmt += formatSyntaxErrorLocation(error);
- fmt += formatExceptionStack(error);
+ if (showStack)
+ fmt += formatExceptionStack(error);
return fmt;
}
const seenCauses = new Set([error]);
- fmt += formatExceptionWithCause(error, seenCauses);
+ fmt += formatExceptionWithCause(error, seenCauses, showStack);
return fmt;
} catch (e) {
return `(could not display error: ${e})`;
import * as Config from '../misc/config.js';
import * as ExtensionDownloader from './extensionDownloader.js';
+import {formatError} from '../misc/errorUtils.js';
import {ExtensionState, ExtensionType} from '../misc/extensionUtils.js';
import * as FileUtils from '../misc/fileUtils.js';
import * as Main from './main.js';
if (!extension)
return;
- const message = error instanceof Error
- ? error.message : error.toString();
+ const message = formatError(error, {showStack: false});
console.debug(`Changing state of extension ${uuid} to ERROR`);
extension.error = message;